﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GenericQueue
{
    class Queue<T>
    {
        private T[] list;
        private int position;
        private int size;

        public Queue(int size)
        {
            this.size = size;
            list = new T[size];
        }

        public void Push(T input)
        {
            if (position == size)
            {
                Console.WriteLine("Overflow!");
            }
            if (position == -1)
            {
                Console.WriteLine("Underflow!");
            }
            else
            {
                list[position++] = input;
            }
        }

        public T Pop()
        {
            if(position < 0)
            {
                Console.WriteLine("Underflow!");
            }
            T output = list[0];
            for (int i = 0; i < size - 1; i++)
            {
                list[i] = list[i + 1];
            }
            list[size - 1] = default(T);
            position--;
            return output;
        }
    }
}
